﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HenIT.Data.SqlClient;
using System.Data.SqlClient;
using System.Data;
namespace EventScavenger
{
    public partial class EventScavengerDAL : GenericSQLServerDAL
    {
        internal List<Reaper> GetReaperList()
        {
            List<Reaper> reapers = new List<Reaper>();
            string sql = "SelectReaperList";
            DataSet reaperds = GetDataSet(sql, CommandType.StoredProcedure);
            if (reaperds.Tables.Count > 0 && reaperds.Tables[0].Rows.Count > 0)
            {
                reapers.AddRange(
                        (from DataRow r in reaperds.Tables[0].Rows
                         select new Reaper()
                         {
                             ReaperId = (int)r["ReaperID"],
                             ServerName = r["ServerName"].ToString()
                         }
                        )
                        );
            }
            return reapers;
        }
        internal void DeleteReaper(Reaper rs)
        {
            string sql = "DeleteReaper";
            SqlParameter[] parameters = new SqlParameter[] 
				{
					new SqlParameter("@ReaperID", rs.ReaperId)
				};
            ExecuteSP(sql, parameters);
        }
        public void UpdateReaper(Reaper rs)
        {
            string sql = "UpdateReaper";
            SqlParameter[] parameters = new SqlParameter[] 
				{
					new SqlParameter("@ReaperID", rs.ReaperId),
					new SqlParameter("@ServerName", rs.ServerName)
					
				};
            ExecuteSP(sql, parameters);
        }
        public void InsertReaper(Reaper rs)
        {
            string sql = "InsertReaper";
            SqlParameter[] parameters = new SqlParameter[] 
				{
					new SqlParameter("@ServerName", rs.ServerName)
				};
            ExecuteSP(sql, parameters);
        }        
    }
}
